<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$app->get('/', function () use ($app) {
    //return $app->welcome();
    echo 'i am wechat-api.';
});

$app->get('/time', function(){
    echo 'i am wechat-api.';
});

$app->get('/demo', function(){

});

//$app->get('/demotest', 'DemoTestController@test');           //单元测试
//$app->post('/demo/testPayNotify','DemoTestController@testPayNotify');//测试支付回调业务处理
//$app->post('/demo/testUploadImage','DemoTestController@testUploadImage');//测试上传文件
//地区json生成
//$app->get('/regions/tree','RegionController@tree');

$app->post('/pingpp/notify', 'PingppController@postNotify');        //支付回调

$app->group(['namespace' => 'App\Http\Controllers',
    'middleware'=>['check.whitelist']], function($app)
{
    $app->post('/xiangdd/useraccount/{user_id:[0-9]+}/apply_takecash','UserAccountController@postTakeCashApply');//提现审核
    $app->post('/xiangdd/useraccount/{user_id:[0-9]+}/approval_takecash/{apply_id:[0-9]+}/','UserAccountController@postTakeCashApproval');//提现操作
    $app->post('/pingxx/refund','PingppController@postRefund');
    $app->post('/config/clear_cache','ConfigController@forgetConfig');
});

/** 匿名操作  **/
$app->group(['namespace' => 'App\Http\Controllers',
    'middleware'=>['check.args']], function($app)
{
    //首页
    $app->get('/xiangdd/city_data', 'HomeController@getCityData');        //获取首页数据
    $app->get('/xiangdd/locate', 'HomeController@getLocation');           //获取定位数据
    $app->get('/recommends/list', 'LayoutRecommendController@getLayoutRecommends');     //获取精彩推荐

    $app->get('/xiangdd/search', 'HomeController@search');               //搜索
    //地区
    $app->get('/regions/selectcity','RegionController@getListByLocation');
    //文章
    $app->get('/articles/{id:[0-9]+}','ArticleController@detail');          //根据ＩＤ获取详情
    $app->get('/articles/code/{code}','ArticleController@detailByCode');    //根据ＣＯＤＥ获取详情

    //登录/退出
    //$app->post('/usercenter/smslogin', 'UserController@smslogin');                //用户登录
    $app->post('/usercenter/login', 'UserController@login');                //用户登录
    $app->post('/usercenter/register', 'UserController@register');         //用户注册
//    $app->post('/usercenter/weibologin', 'UserController@createIfnotExistWB');  //微博登录
//    $app->post('/usercenter/qqlogin', 'UserController@createIfnotExistQQ');  //QQ登录
//    $app->post('/usercenter/weixinlogin', 'UserController@createIfnotExistWX');  //微博登录
    $app->post('/usercenter/wxcodelogin', 'UserController@createIfnotExistWXCode');  //微信内登录
    $app->post('/wx/jsapi_ticket', 'UserController@wxGetSign');        //获取微信登录信息

    //SMS
    $app->post('/sms/sendcode', 'SMSController@sendcode');                  //获取验证码
    //$app->post('/sms/checkcode', 'SMSController@checkcode');               //验证验证码
    $app->post('/usercenter/reset_pwd', 'UserController@findPwd');   //密码重置

    //物流查询
    $app->get('/logistics/query','LogisticsController@query');

    //代言人
    $app->get('/store/{store_id:[0-9]+}/villagers', 'StoreController@getStoreVillagers');//代言人列表
    $app->post('/store/{store_id:[0-9]+}/villagers/apply', 'StoreController@postApplyVillagers');//申请代言人

    //线路
    $app->get('/tours/list_bycate/{cate_id:[0-9]+}', 'TourController@getToursByCate');  //根据线路主题获取线路
    $app->get('/tours/{tour_id:[0-9]+}/comments', 'TourController@getComments');         //线路评论
    //    $app->get('/tour/list', 'TourController@getList');            //获取路线详情

    $app->get('/tour/schedule/{tour_id:[0-9]+}', 'TourController@getScheduleByMonth'); //根据月份获取线路日程
    $app->get('/tour/{tour_id:[0-9]+}/tuan_list', 'TourTuanController@getList');          //获取指定线路下的团列表

    //民宿
    $app->get('/hotels/list', 'HotelController@getHotelsList');  //根据民宿列表

    //农家乐
    $app->get('/restaurants/list', 'RestaurantsController@getRestaurantsList');  //根据农家乐列表

    //土特产
    $app->get('/goods/list', 'GoodsController@getGoodsList');  //土特产列表
    $app->get('/goods/{goods_id:[0-9]+}/comments', 'GoodsController@getComments');                //商品评论

    //做地主
    $app->get('/landowners/list','LandownersController@getLandownersList');     //做地主列表
    $app->get('/landowners/{landowners_id:[0-9]+}/comments', 'LandownersController@getComments');                //做地主评论

    //村相关
    $app->get('/stores/{store_id:[0-9]+}/index','StoreController@getIndex'); //首页
    $app->get('/stores/{store_id:[0-9]+}/intro','StoreController@getIntro'); //村介绍
    $app->get('/stores/{store_id:[0-9]+}/partner_intro','StoreController@getPartnerIntro'); //村合伙人介绍
    $app->get('/stores/{store_id:[0-9]+}/tours','StoreController@getTours'); //游乡村列表
    $app->get('/stores/{store_id:[0-9]+}/goods','StoreController@getGoods'); //定土货
    $app->get('/stores/{store_id:[0-9]+}/hotels','StoreController@getHotels'); //住民宿
    $app->get('/stores/{store_id:[0-9]+}/restaurants','StoreController@getRestaurants'); //吃土菜
    $app->get('/stores/{store_id:[0-9]+}/landowners','StoreController@getLandowners'); //做地主

});

/** 半匿名操作  **/
$app->group(['namespace' => 'App\Http\Controllers',
    'middleware'=>['check.args','check.auth_o']], function($app)
{
    /** 半匿名操作  **/
    $app->get('/goods/{goods_id:[0-9]+}', 'GoodsController@getDetail');      //商品详情（根据用户收藏状态不同）
//    //团详情
//    $app->get('/tuans/{tuan_id:[0-9]+}', 'TuanController@getDetail');      //团详情（根据用户收藏状态不同）
    //民宿
    $app->get('/hotels/{hotels_id:[0-9]+}', 'HotelController@getHotelsDetail');  //根据民宿列表
    //吃土菜
    $app->get('/restaurants/{restaurants_id:[0-9]+}', 'RestaurantsController@getRestaurantsDetail');  //根据吃土菜列表
    $app->get('/tour/{tour_id:[0-9]+}', 'TourController@getDetail');            //获取路线详情
    $app->get('/tourTuan/{tuan_id:[0-9]+}', 'TourTuanController@getDetail');     //我的旅游拼团列表
    //做地主详情
    $app->get('/landowners/{landowners_id:[0-9]+}', 'LandownersController@getDetail');
});

/** 需要登录后的操作  **/
$app->group(['namespace' => 'App\Http\Controllers',
    'middleware'=>['check.args','check.auth']], function($app)
{
    //用户中心
    $app->post('/usercenter/{user_id:[0-9]+}/logout', 'UserController@logout');        //用户注销
    //$app->post('/usercenter/{user_id:[0-9]+}/modifypwd', 'UserController@modifyPwd');    //修改密码
    $app->post('/usercenter/{user_id:[0-9]+}/avatar', 'UserController@updatePortrait'); //修改头像
    $app->get('/usercenter/{user_id:[0-9]+}', 'UserController@getProfile');            //获取用户信息
    $app->put('/usercenter/{user_id:[0-9]+}', 'UserController@editProfile');           //编辑用户信息

    //我的地址
    $app->get('/users/{user_id:[0-9]+}/addresses', 'AddressController@lists');       //我的地址列表
    $app->post('/users/{user_id:[0-9]+}/addresses', 'AddressController@add');        //我的地址新增
    $app->put('/users/{user_id:[0-9]+}/addresses/{addr_id:[0-9]+}', 'AddressController@edit');        //我的地址修改
    $app->delete('/users/{user_id:[0-9]+}/addresses/{addr_id:[0-9]+}', 'AddressController@delete');  //我的地址删除
    $app->post('/users/{user_id:[0-9]+}/addresses/{addr_id:[0-9]+}/set_default', 'AddressController@setDefault');     //设置默认地址
    $app->get('/users/{user_id:[0-9]+}/addresses/get_default', 'AddressController@getDefault');     //获取默认地址

    //出行人
    $app->get('/users/{user_id:[0-9]+}/travelers', 'PeopleTravelController@lists');        //出行人列表
    $app->post('/users/{user_id:[0-9]+}/travelers', 'PeopleTravelController@add');        //出行人增加
    $app->post('/users/{user_id:[0-9]+}/travelers/{traveler_id:[0-9]+}', 'PeopleTravelController@edit');       //出行人编辑
    $app->delete('/users/{user_id:[0-9]+}/travelers/{traveler_id:[0-9]+}', 'PeopleTravelController@delete');   //出行人删除
    $app->post('/users/{user_id:[0-9]+}/travelers/bulk_delete', 'PeopleTravelController@bulk_delete');        //出行人批量删除

    //我的收藏
    $app->get('/users/{user_id:[0-9]+}/collects/tour','CollectsController@getTourCollectionList');
    $app->get('/users/{user_id:[0-9]+}/collects/goods','CollectsController@getGoodsCollectionList');
    $app->get('/users/{user_id:[0-9]+}/collects/hotels','CollectsController@getHotelCollectionList');
    $app->get('/users/{user_id:[0-9]+}/collects/restaurants','CollectsController@getRestaurantsCollectionList');
    $app->get('/users/{user_id:[0-9]+}/collects/landowners','CollectsController@getLandownersCollectionList');
    $app->post('/goods/{id:[0-9]+}/collect', 'CollectsController@collectGoods');  //收藏
    $app->post('/tours/{id:[0-9]+}/collect', 'CollectsController@collectTours');  //收藏
    $app->post('/hotels/{id:[0-9]+}/collect', 'CollectsController@collectHotels');  //收藏
    $app->post('/restaurants/{id:[0-9]+}/collect', 'CollectsController@collectRestaurant');  //收藏
    $app->post('/landowners/{id:[0-9]+}/collect', 'CollectsController@collectLandowners');  //收藏

    //购物流程
    //-----------------旅游购物下单接口--------------------
    $app->get('/cashier/tour/initTourSingle', 'TourCashierController@initTourSingle');          //立即购买旅游路线选择出行人确认页
    $app->post('/order/tour/createTourOrderSingle', 'TourOrdersController@createTourOrderSingle');          //立即购买旅游路线订单创建
    $app->get('/cashier/tour/initCreateTourGroup', 'TourCashierController@initCreateTourGroup');          //旅游路线开启团购选择出行人确认页
    $app->post('/order/tour/createTourOrderGroup', 'TourOrdersController@createTourOrderGroup');          //旅游路线合买订单创建即团创建
    $app->get('/cashier/tour/initJoinTourGroup', 'TourCashierController@initJoinTourGroup');          //旅游路线参加团购选择出行人确认页
    $app->post('/order/tour/joinTourOrderGroup', 'TourOrdersController@joinTourOrderGroup');          //旅游路线合买订单创建即团创建
    $app->post('/users/{user_id:[0-9]+}/tourOrders/{order_id:[0-9]+}/pay_para','TourOrdersController@gotoPayTourOrder'); //获取支付链接
    //------------------旅游购物下单结束-------------------

    $app->get('/cashier/initByGoods', 'CashierController@initByGoods');          //立即购买商品结算
    $app->post('/cashier/createOrderByGoods', 'CashierController@createOrderByGoods');          //单个商品生成订单
    $app->post('/users/{user_id:[0-9]+}/orders/{order_id:[0-9]+}/pay_para', 'CashierController@gotoPay');//获取支付链接



    //-------------------做地主下单------------------
    $app->get('/landowners/initByLandowners', 'LandownersOrderController@initByLandowners');          //立即购买结算
    $app->post('/landowners/createOrderByLandowners', 'LandownersOrderController@createOrderByLandowners');          //生成订单
    $app->post('/users/{user_id}/landownersOrders/{id}/cancel', 'LandownersOrderController@cancel');       //取消订单
    $app->delete('/users/{user_id}/landownersOrders/{id}', 'LandownersOrderController@delete');       //删除做地主订单
    $app->get('/users/{user_id:[0-9]+}/landownersOrders', 'LandownersOrderController@lists');                     //全部订单列表
    $app->get('/users/{user_id}/landownersOrders/{id}', 'LandownersOrderController@detail');    //订单详细
    $app->post('/users/{user_id}/landownersOrder/{id}/confirm', 'LandownersOrderController@confirm'); //确认收货
    $app->get('/users/{user_id}/landownersOrder/{id}/refund', 'LandownersOrderController@getApplyRefund');//退货退款
    $app->post('/users/{user_id}/landownersOrder/{id}/refund', 'LandownersOrderController@postApplyRefund');     //退款
    $app->post('/users/{user_id}/landownersOrder/{id}/cancel_refund', 'LandownersOrderController@cancelRefund'); //取消退款申请
    $app->post('/users/{user_id}/landownersOrder/{id}/complain', 'LandownersOrderController@complain');     //投诉
    $app->post('/users/{user_id:[0-9]+}/landownersOrders/{order_id:[0-9]+}/pay_para', 'LandownersOrderController@gotoPay');//获取支付链接
    $app->post('/users/{user_id}/landownersOrders/{id}/evaluate', 'LandownersOrderController@postEvaluate');     //评论


    //拼团相关信息
    //----------------旅游拼团相关---------------------------
    $app->get('/users/{user_id:[0-9]+}/tourTuan', 'TourTuanController@getMyList');     //我的旅游拼团列表
    //----------------旅游拼团相关结束------------------------

    //我的订单
    //----------------旅游订单相关---------------------------
    $app->get('/users/{user_id:[0-9]+}/tourOrders', 'TourOrdersController@lists');     //全部订单列表
    $app->get('/users/{user_id:[0-9]+}/tourOrders/{id}', 'TourOrdersController@detail');    //查看具体订单详细

    $app->post('/users/{user_id}/tourOrders/{id}/cancel', 'TourOrdersController@cancel');       //取消订单
    $app->delete('/users/{user_id}/tourOrders/{id}', 'TourOrdersController@delete');       //删除订单

    $app->post('/users/{user_id}/tourOrders/{id}/evaluate', 'TourOrdersController@evaluate');     //评论
    $app->post('/users/{user_id}/tourOrders/{id}/complain', 'TourOrdersController@complain');     //投诉

    $app->get('/users/{user_id}/tourOrders/{id}/refund', 'TourOrdersController@getApplyRefund');       //退款申请
    $app->post('/users/{user_id}/tourOrders/{id}/refund', 'TourOrdersController@postApplyRefund');     //退款
    $app->post('/users/{user_id}/tourOrders/{id}/cancel_refund', 'TourOrdersController@postCancelRefund'); //取消退款申请
    //----------------旅游订单相关结束------------------------

    $app->get('/users/{user_id}/orders', 'OrdersController@lists');                     //全部订单列表
    //$app->get('/users/{user_id}/orders/after_sale', 'OrdersController@afterSaleList'); //售后列表
    $app->get('/users/{user_id}/orders/{id}', 'OrdersController@detail');    //查看具体订单详细
    $app->post('/users/{user_id}/orders/{id}/cancel', 'OrdersController@cancel');       //取消订单
    $app->delete('/users/{user_id}/orders/{id}', 'OrdersController@delete');       //删除订单
    $app->post('/users/{user_id}/orders/{id}/confirm', 'OrdersController@confirm');     //确认收货
//    $app->post('/orders/allcountlist', 'OrdersController@allcountlist');     //各个订单导航下的数据
    $app->get('/users/{user_id}/orders/{id}/refund', 'OrdersController@getApplyRefund');       //退款申请
    $app->post('/users/{user_id}/orders/{id}/refund', 'OrdersController@postApplyRefund');     //退款
    $app->post('/users/{user_id}/orders/{id}/cancel_refund', 'OrdersController@cancelRefund'); //取消退款申请
//    $app->get('/users/{user_id}/orders/{id}/express_history', 'OrdersController@expressHistory');    //查看物流
    $app->get('/users/{user_id}/orders/{id}/return_goods', 'OrdersController@getReturnGoods');       //退货
    $app->post('/users/{user_id}/orders/{id}/return_goods', 'OrdersController@postReturnGoods');       //退货
    $app->get('/users/{user_id}/orders/{id}/change_expressno', 'OrdersController@getModifyExpress'); //修改单号
//    $app->get('/orders/express_history','Kuaidi100Controller@getHistory');      //查看物流
//    $app->get('/users/{user_id}/orders/{id}/evaluate', 'OrdersController@getEvaluate');     //评论
    $app->post('/users/{user_id}/orders/{id}/evaluate', 'OrdersController@postEvaluate');     //评论
    $app->post('/users/{user_id}/orders/{id}/complain', 'OrdersController@complain');     //投诉

//    //支付 配送
//    $app->get('/payments', 'PaymentController@lists');           //支付方式
//    $app->get('/shippings', 'ShippingController@lists');         //配送方式

    //支付宝
//    $app->get('/users/{user_id:[0-9]+}/orders/{order_id:[0-9]+}/pay_para', 'PingppController@getPayPara');
//    $app->get('/users/{user_id:[0-9]+}/orders/{order_id:[0-9]+}/pay_fullpara', 'PingppController@getFullPayPara');

    //我的团
    //团列表
    $app->get('/users/{user_id}/tuan_list', 'TuanController@getList');      //团列表

    //绑定手机
    //$app->get('/usercenter/{user_id:[0-9]+}/bind_mobile','UserController@bind_mobile');
    $app->get('/users/{user_id}/orders/{id}/tuan', 'OrdersController@order_tuan');    //查看团详情 tuan_id
});